<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <link rel="shortcut icon" href="../../src/images/bitbug_favicon.ico" type="image/x-icon">
  <meta name="keywords" content="your keywords">
  <meta name="description" content="your description">
  <meta name="author" content="author,email address">
  <meta name="robots" content="index,follow">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <title>仁和区党群服务一号通暨群众意见受理中心</title>
  <link rel="stylesheet" href="../../src/css/base.css">
  <link rel="stylesheet" href="../../src/css/common.css">
  <link rel="stylesheet" href="../../src/css/tpl.css">
  <link rel="stylesheet" href="../../src/css/consult.css">
  <script src="../../src/js/libs/es5-shim.min.js"></script>
  <script src="../../src/js/libs/es5-sham.min.js"></script>
  <script src="../../src/js/libs/json3.min.js"></script>
  <style>
  .consultation_list_news {
    width: 600px;
  }
  </style>
</head>

<body>
  <div class="page">
    <div id="header"></div>
    <div class="menu-bar">
      <div class="container">
        <span>
                    <span class="crumb-name">当前你的位置：</span>>
        </span>
        <span>
                    <a class="" href="../../views/Home/Index.html">首页</a>>
                </span>
        <span>办事咨询</span>
        <div class="fr search_bar clearfix">
          <input class="fl search_input" placeholder="请输入关键字..." type="text" id="js_sreach_box">
          <i class="fl search_icon"></i>
        </div>
      </div>
    </div>
    <div class="mid_container clearfix">
      <div class="left_guide">
        <h1 class="left_guide_top_size">办事咨询</h1>
        <div class="left_guide_decorate"></div>
        <div class="left_about_us">CONSULTATION</div>
        <div id="menu_html"></div>
      </div>
      <div class="mid_guide">
        <div class="mid_guide_content">
          <div class="content">
            <div class="consultation_list" id="consult_html"></div>
          </div>
          <div id="page1" class="laypage"></div>
        </div>
      </div>
    </div>
  </div>
  <div id="footer"></div>
  <script id="menu_tpl" type="text/html">
    {{each list val i}}
    <div class="left_white_about js_menu_list" data-typeid="{{val.id}}">
      <a href="javascript:;"><span class="left_cn_about_us">{{val.typename}}</span></a>
    </div>
    {{/each}}
  </script>
  <script type="text/html" id="consult_tpl">
    {{each resultdata val idx}}
    <a href="../News/Detail.html?id={{val.id}}" class="consultation_list_mouse">
      <div class="consultation_list_one">
        <div class="point"></div>
        <span class="consultation_list_news fof">{{val.title}}</span>
        <span class="consultation_list_times">[{{val.publishtime.split(' ')[1]}}]</span>
      </div>
    </a>
    {{/each}} {{if resultdata.length == 0}}
    <div class="empty_box">
      <img src="../../src/images/null_state.png" alt="">
    </div>
    {{/if}}
  </script>
  <script src="../../src/js/libs/jquery.1.12.4.js"></script>
  <script src="../../src/js/libs/template-web.js"></script>
  <script src="../../src/js/libs/laypage/laypage.js"></script>
  <script src="../../src/js/base/common.js"></script>
  <script>
    var params = {
      typeid: 0,
      keyword: ' ',
      page: 1
    }

    var pageindex = 3

    try {
      params.keyword = decodeURI(window.location.href.split('?')[1].split('=')[1])
    } catch (error) {
      console.log(error)
    }

    $(document).on('click', '.js_menu_list', function () {
      params.typeid = $(this).attr('data-typeid')
      params.keyword = ' '
      $(this).addClass('active').siblings().removeClass('active')
      getList(parseInt(params.typeid), 1)
    })

    $('.search_icon').on('click', function () {
      params.keyword = $('.search_input').val()
      getList(params.typeid, 1)
    })

    $('#js_sreach_box').on('keyup', function (e) {
      if (e.keyCode == 13) {
        params.keyword = $('.search_input').val()
        getList(params.typeid, 1)
      }
    })

    getMenu()

    function getMenu() {
      $.ajax({
        type: "GET",
        url: "http://221.10.2.222:5680/api/ow/NewsType/TypeList/2",
        dataType: "json",
        success: function (res) {
          var data = {
            list: res
          }
          var html = template('menu_tpl', data);
          document.getElementById('menu_html').innerHTML = html;
          $('.js_menu_list').eq(0).addClass('active')
          params.typeid = res[0].id
          getList(params.typeid, 1)
        }
      })
    }

    function getList(type, page) {
      $.ajax({
        url: 'http://221.10.2.222:5680/api/ow/news/list',
        type: "GET",
        dataType: "json",
        data: {
          page: page,
          type: type,
          keyword: params.keyword,
          pagesize: 17
        },
        success: function (res) {
          res.resultdata = JSON.parse(res.resultdata)
          console.log(res)
          var consult = template('consult_tpl', res)
          $('#consult_html').html(consult)
          laypage({
            cont: 'page1',
            pages: Math.ceil(res.count / 17),
            curr: page || 1,
            first: false,
            last: false,
            prev: '<',
            next: '>',
            jump: function (obj, first) {
              // window.scrollTo(0, 0)
              if (!first) {
                getList(params.typeid, obj.curr);
              }
            }
          });
        },
        error: function (e) {
          console.log(e)
        }
      })
    }
  </script>
</body>

</html>